﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using System.Web.Script.Serialization;
namespace Golf.WebUI.HttpHandler.Attribute
{
    /// <summary>
    /// $codebehindclassname$ 的摘要说明
    /// </summary> 
    public class Golf_ProAttrDetailZSG : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            JavaScriptSerializer js = new JavaScriptSerializer();
            //获得客服端
            string action = context.Request.QueryString["action"];
            if (action == "rad_Type")
            {
                //加载类型
                Golf.BLL.Golf_ProductType bll = new Golf.BLL.Golf_ProductType();
                List<Golf.Model.Golf_ProductType> list = bll.DataTableToList(bll.GetList("").Tables[0]);
                context.Response.Write(js.Serialize(list));
            }
            if (action == "rad_pingpai")
            {
                //加载 品牌
                Golf.BLL.Golf_BrandType bll = new Golf.BLL.Golf_BrandType();
                List<Golf.Model.Golf_BrandType> list = bll.DataTableToList(bll.GetList("").Tables[0]);
                context.Response.Write(js.Serialize(list));
            }

            Golf.BLL.Golf_Product bll_pro = new Golf.BLL.Golf_Product();
            if (action == "type_pro")
            {
                //加载产品  按类型
                string Pro_TypeId = context.Request.QueryString["ids"];
                List<Golf.Model.Golf_Product> list = bll_pro.DataTableToList(bll_pro.GetList("Pro_TypeId=" + Pro_TypeId).Tables[0]);
                context.Response.Write(js.Serialize(list));
            }
            if (action == "type_pingpai")
            {
                //加载产品  按品牌
                string Pro_BrandTypeId = context.Request.QueryString["ids"];
                List<Golf.Model.Golf_Product> list = bll_pro.DataTableToList(bll_pro.GetList("Pro_BrandTypeId=" + Pro_BrandTypeId).Tables[0]);
                context.Response.Write(js.Serialize(list));
            }
            if (action == "attr")
            {
                //加载 子类属性
                string id = context.Request.QueryString["id"];
                Golf.BLL.Golf_Attribute bll = new Golf.BLL.Golf_Attribute();
                List<Golf.Model.Golf_Attribute> list = bll.DataTableToList(bll.GetList("ParentID=" + id + " and AttrParent is NULL and AttrChild is not null").Tables[0]);
                context.Response.Write(js.Serialize(list));
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
